package com.powernode.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.powernode.dto.CustomerDto;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.powernode.mapper.CustomerMapper;
import com.powernode.domain.Customer;
import com.powernode.service.CustomerService;

import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService{

    @Resource
    private CustomerMapper customerMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return customerMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Customer record) {
        return customerMapper.insert(record);
    }

    @Override
    public int insertSelective(Customer record) {
        return customerMapper.insertSelective(record);
    }

    @Override
    public Customer selectByPrimaryKey(Integer id) {
        return customerMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Customer record) {
        return customerMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Customer record) {
        return customerMapper.updateByPrimaryKey(record);
    }

    @Override
    public Page<Customer> queryForPage(CustomerDto customerDto) {
        Page<Customer> page= PageHelper.startPage(customerDto.getPage(),customerDto.getLimit());
        List<Customer> customerList=this.customerMapper.queryAllCustomer(customerDto);
        return page;
    }

    @Override
    public void changeCustomerUser(Integer userId, Integer[] customerIds) {
        this.customerMapper.changeCustomerUser(userId,customerIds);
    }




}
